<?php

/**
 * Flickr Photosets - Invite Page
 * Helps the user to invite their friends who haven't added the application.
 * 
 * @author Brad Dougherty <bdougherty@gmail.com>
 * @license http://www.gnu.org/licenses/gpl.html GNU General Public License 3.0
 */

/*
Require the function library
This will include all other necessary files
*/
require_once 'lib.php';

/*
Initialize Flickr Photosets
*/
$fp = new FP_Canvas(FP_Canvas::require_login, true, false);

if (isset($_GET['all'])) {
	
	// Get list of friends who have this app installed
	$friends_to_exclude = $fp->get_friends_with_app();
	
	$about_text = 'Using this page you can invite any of your friends to use <fb:application-name linked="false" />. If you want to see only your Facebook friends that are also in your contacts on Flickr, <a href="'.$fp->canvas_url.'/invite.php">show the invite box with only your Flickr contacts</a>.';
	
}
else {
	
	// Get a list of friends who are not on flickr
	$friends_to_exclude = (isset($_GET['loose'])) ? $fp->get_friends_not_on_flickr(true) : $fp->get_friends_not_on_flickr();
	$friends_to_exclude .= ','.$fp->get_friends_with_app();
	
	$about_text = 'We\'ve done our best to find your Facebook friends that are also in your Flickr contacts, but have not yet added <fb:application-name linked="false" />. If you know that one of your Facebook friends has a Flickr account, but they are not in the list below, <a href="'.$fp->canvas_url.'/invite/?all">show the invite box with all of your friends</a>.';
		
}

// The invite box text
$invite_fbml = '<fb:name uid="'.$fp->uid.'" firstnameonly="true" shownetwork="false"/> wants you to share your Flickr photos on Facebook.<fb:req-choice url="http://www.facebook.com/add.php?api_key='.FACEBOOK_API_KEY.'" label="Add '.$fp->application_name.'" />';

?>

<fb:title>Invite your friends</fb:title>
<?=$fp->get_stylesheet('invite')?>
<?=$fp->get_header('invite', 'Invite your friends to <fb:application-name linked="false" />', true)?>

<div class="info_message">
	<?=$about_text?>
</div>

<fb:request-form type="invitation" content="<?=htmlentities($invite_fbml)?>" action="<?=$fp->canvas_url?>/">
	<fb:multi-friend-selector actiontext="Invite your friends to use <?=$fp->application_name?>." bypass="cancel" max="10" exclude_ids="<?=$friends_to_exclude?>" />
</fb:request-form>

<?=$fp->echo_footer(true)?>